<template>
  <div>
    <h2>充电启动</h2>
    <div>
      <p>终端编号: {{ terminalId }}</p>
      <button @click="startCharging">启动</button>
    </div>
  </div>
</template>

<script>
import api from "@/api";

export default {
  data() {
    return {
      terminalId: "T10928232873201",
      orderId: null,
    };
  },
  methods: {
    async startCharging() {
      try {
        const response = await api.startCharging(this.terminalId);
        this.orderId = response.data.orderId;
        this.$router.push(`/charging/${this.orderId}/in-progress`);
      } catch (error) {
        alert("启动失败：" + error.message);
      }
    },
  },
};
</script>
